﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;


namespace MixScript.BLL.FI
{
    public class cGroup : cBaseBLL
    {
        public cGroup() { }


        public bool getGroupCOA(ref DataTable dt)
        {
            try
            {

                dt = new DataTable();
                string sSQL = @"SELECT * FROM
                            (SELECT null Parentid, g.groupnum as idcoa, g.groupname coaName FROM accgroup g
                            union
                            SELECT s.groupnum Parentid,s.subnum idcoa,s.subname coaName FROM accsubgroup s) t
                            ORDER BY Parentid,idcoa, coaName";

                dt = Dbserver.ExecuteQuery(sSQL, "vw_coamst");


                return dt.Rows.Count > 0;
            }
            catch (Exception ex)
            {

                throw ex;
            }

        }

        public bool getGroupCOA(ref DataTable dt, int Groupid)
        {
            try
            {
                dt = new DataTable();
                string sSQL = @"SELECT * FROM accgroup g
                            where groupnum = {0}";
                dt = Dbserver.ExecuteQuery(string.Format(sSQL, Groupid), "vw_coamst");
                return dt.Rows.Count > 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
    }

}
